<?
require("config.php");

$location_status .= "| Edit";
$show_backnav = "catalog_menu";
$menuname = NULL;
$menutarget = NULL;

if (NULL!=$action){

	$dir = "med_catalog/";


	if ($remove_File=="ture") $File_name=NULL;

	if ($Picture) { 
		@copy($Picture."/".$Picture_name,"../../../pictures/e-receipt.jpg");
		
		//die($Picture."/".$Picture_name);
		myUpload($Picture,$Picture_name,$dir);
		@copy("../../../pictures/med_catalog/".$Picture_name,"../../../pictures/e-receipt.jpg");
		
	}
	if ($Picture_name == null) $Picture_name = $bk_Picture;
	if ($sm_Picture) myUpload($sm_Picture,"sm_" . $Picture_name,$dir);
	if ($remove_1=="ture") $Picture_name=NULL;

	if ($File_name) myUpload($File,$File_name,$dir);
	if ($File_name=="" || $File_name==NULL) $File_name=$old_File;



   $field = array(
	"code", 
	"name", 
	"file", 
	"picture",
	"auth",
	);


   $content = array(
	$Code,
	$Name,
	$File_name,
	$Picture_name,
	$Auth,
	);

	$exp = "id=$id";

   myUpdate($table,$field,$content,$exp);



   header("location:" . $rela_path . "share/msg.php?v=47");

   exit();

}else{

  if (!checkRecord($table,$id)){

	header("location:" . $rela_path . "share/msg.php?v=9002");

	exit();
  
  }

}


$Query = "SELECT 
code,
name,
file,
picture,
auth 
FROM $table WHERE id=$id LIMIT 1";

$r=myQuery($Query);

$Code=$r[0][0];
$Name=$r[0][1];
$File=$r[0][2];
$Picture = $r[0][3];
$Auth = $r[0][4];

require($rela_path . "inc/header.php");

?>



<form action="" method="post" enctype="multipart/form-data" name="form1">
<input name="action" type="hidden" value="edit">
<input name="id" type="hidden" value="<?print($id)?>">
<input name="Code" type="hidden" value="<?print($Code)?>">
<input name="old_File" type="hidden" value="<?print($File)?>">

<input name="bk_Picture" type="hidden" value="<?print($Picture)?>">




<table width="95%" border="0" align="center">
  <tr> 
    <td valign="top"><p> 
      <table width="100%" border="0" cellspacing="5" cellpadding="1">
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr> 
          <td class="tdheader">Code :</td>
          <td><?print($Code)?></td>
        </tr>



<!--        <tr> 
          <td class="tdheader">Viewed by member only:</td>
          <td>
<?
$sourceData = array(
1,
0,
);

$sourceLabel = array(
"Yes",
"No",

);

$boxName = "Auth";

$value = $Auth;

FFPRadioBox($boxName,$value,$sourceData,$sourceLabel);


?>

</td>
        </tr>
-->


        <tr> 
          <td class="tdheader">Name :</td>
          <td><input type="text" class="text" name="Name" size="40" value="<?print($Name)?>"></td>
        </tr>
<!--        <tr> 
          <td class="tdheader">Download File :</td>
          <td>
		  <?loadFile($File,$rela_path . $PIC_DIR . "$table/")?>
		  <?removeFile($File,"remove_File")?>
		  <input type="File" class="text" name="File" size="40"></td>
        </tr>
-->
          <tr> 
            <td class="tdheader">Picture</td>
            <td>
			
			<?removeImage($Picture,"remove_1")?>
			
			<!--<br><b>(Normal Picture)</b><br>-->
			<?loadImage($Picture,$rela_path . $PIC_DIR . "$table/")?> 
			<input type="file" class="text" name="Picture" size="40">

<!--			<br><b>(Smaller Picture)</b><br>
			<?loadSmallImage($Picture,$rela_path . $PIC_DIR . "$table/")?>
			<input type="file" class="text" name="sm_Picture" size="40">
-->			<br><br>


            </td>
          </tr>


        <tr> 
          <td>&nbsp;</td>
          <td><input type="image" src="../../images/bt_cancel.gif" onClick="Redirect('catalog_menu.php',1);return false;"> <input type="image" src="../../images/bt_save.gif"></td>
        </tr>
        <tr> 
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
      </table>
      <p>
      <p>
      <p> <br>
      <p><br>
        <br>
        <br>
        <br>
      <p> 
      <p> 
      <p> </td>
  </tr>
</table>
<br>
<br>
<br>
<?
require($rela_path . "inc/footer.php");
?>
